<?php

namespace adminmatrix\admin;

use adminmatrix\admin\lists\BaseListsData;
use adminmatrix\admin\service\JsonService;
use think\App;
use think\Container;
use think\Request;
use adminmatrix\swoole\Websocket;

abstract class BaseController
{
    protected App $app;
    protected Request $request;

    protected Websocket $websocket;
    public function __construct(App $app , Container $container)
    {
        $this->app = $app;
        $this->request = $this->app->request;
        $this->websocket = $container->make(Websocket::class);
    }



    

    public function emit(array $data ){

    }


    public function dataLists( ?BaseListsData $lists = null){
        if (empty($lists) ||is_null($lists)) {
            $listName = str_replace('.' , '\\' , $this->app->getNamespace() . '\\lists\\' . $this->request->controller() . ucwords($this->request->action()));
            $lists    = invoke($listName);
        }
        return JsonService::dataLists($lists);
    }

}